fix(search): show freeform genre as a selected filter chip#14489
Merged
Conversation
Clicking a freeform/custom genre (e.g. "Hyperpop Fusion") on a track page navigates to search and the genre IS passed to the search API, but the genre filter chip showed no indication of what was being filtered. The FilterButton resolves its active label by matching the URL genre value against its options, which are built from the ~51 hardcoded GENRES. A freeform genre matches nothing, so selectedLabel is undefined and the chip falls back to the generic "Genre" text. Add the current genre as an option when it isn't in the predefined list so it renders as a selected chip on both web and mobile. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Contributor
🌐 Web preview readyPreview URL: https://audius-web-preview-pr-14489.audius.workers.dev Unique preview for this PR (deployed from this branch). |
dylanjeffers
added a commit
that referenced
this pull request
Jun 18, 2026
… section (#14497) ## What Replaces the hardcoded trending genre list with the **top genres ranked by recent activity**, fetched dynamically from `/v1/genres/popular`. This is needed now that freeform genres are supported and a static list is no longer sufficient. ## Changes **New hook — `usePopularGenres`** (`packages/common/src/api/tan-query/search/usePopularGenres.ts`) - Fetches the top 25 genres from `/v1/genres/popular` - `staleTime` ~15 min to match the backend cache TTL - Merges the ranked genres with the static list (deduped, popular-first) so ranked genres carry a `count` and the long-tail stays searchable **Trending genre filter — top genres by default + search for long-tail** - Web desktop (`TrendingPageContent.tsx`): `FilterButton` options come from the popular genres, with `showFilterInput` enabled so long-tail genres are searchable - Web mobile genre page (`GenreSelectionList` gains a `topGenres` prop): shows the ranked genres by default, searches the full set - Native mobile drawer (`TrendingFilterDrawer.tsx`): same top-by-default + search-the-long-tail behavior **Freeform-safe selection** — new `toTrendingGenreValue` helper accepts community/freeform genres (unlike `toTrendingGenre`, which dropped any value outside the static `GENRES` list, nullifying freeform selections). Builds on the freeform chip fix from #14489 without regressing it. **Explore "Trending Genres" section** (web + mobile) and edit-track genre suggestions are powered by the same hook. ## Notes / scope - SDK genre endpoint (`GenresApi`, `PopularGenre`, `PopularGenresResponse`) and wiring are included as a dependency. - Unrelated SDK regen drift (Notification/Event/etc.) and the comment-drawer work on the original branch were intentionally **excluded** to keep this PR focused. - Sharing a freeform genre via the trending URL param still won't restore on reload (`isValidGenre` only validates the static list) — in-session selection works; URL restore for freeform genres is left as a follow-up. ## Test plan - `tsc` passes for `common`, `web`, `mobile` - `eslint` passes for all touched files - `genres.test.ts` unit tests pass --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Clicking a freeform/custom genre (e.g. "Hyperpop Fusion") on a track page navigates to search, but the genre doesn't appear as a selected filter chip — leaving no indication of what's being filtered and making it unclear whether the search is filtering by that genre at all.
Root cause
The genre is read from the URL and is passed to the search API (
useSearchResults.ts:177—genre: filters.genre ? [filters.genre] : undefined), so server-side filtering already works.The bug is purely in the filter UI. The harmony
FilterButtonresolves its active label by matching the URL genre value against itsoptions, which are built from the ~51 hardcodedGENRES:A freeform genre matches no option →
selectedLabelisundefined→ the chip falls back to the generic"Genre"label.Fix
In the
GenreFilteron both web and mobile, when the active genre isn't in the predefinedGENRESlist, add it as an option so theFilterButtoncan resolve a label and render it as a selected chip.packages/web/src/pages/search-page/SearchFilters.tsxpackages/mobile/src/screens/search-screen/SearchFilters.tsxNo change needed on the API side — the genre was already passed through correctly.
Testing
eslintclean on both changed filestsc --noEmitpasses for bothpackages/webandpackages/mobile🤖 Generated with Claude Code